<template>
    <div>
        <H1>科室详情</H1>
        <table class="table table-bordered" style="background-color:cadetblue;">
            <tbody>
                <tr>
                    <td>科室名称</td>
                    <td>{{info.name}}</td>
                </tr>
                  <tr>
                    <td>科室人数</td>
                    <td>{{info.people}}</td>
                </tr>
                 <tr>
                    <td>科室介绍</td>
                    <td>{{info.introduce}}</td>
                </tr>
                <tr>
                    <td>科室</td>
                    <td> {{info.oname}}</td>
                </tr>
                <tr>
                    <td>创建时间</td>
                    <td>{{info.createTime.substr(0,10)}}</td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="返回" @click="add"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref} from 'vue'
import axios from 'axios';
import { onMounted } from 'vue';
import { useRoute,useRouter } from 'vue-router';
let route=useRoute();
let router=useRouter();
onMounted(()=>{
    GetLevel();
    fan();
})


let level:any=ref([]);
let info:any=ref({
  "id": 0,
  "name": "",
  "people": "",
  "isdel": false,
  "introduce": "",
  "createTime": "",
  "lid": 0
})

const fan=()=>{
    axios({
        url:'https://localhost:7118/api/Office/Fan',
        method:'get',
        params:{
            id:route.query.id,
        }
    })
    .then((res)=>{
        console.log(res.data);
        const data=res.data[0]
        Object.assign(info.value,res.data)
        // info.value = res.data
    })
    .catch((err)=>{
        console.log(err)
    })
}
const GetLevel=()=>{
      axios({
        url:'https://localhost:7118/api/Office/GetOfficeLevels',
        method:'get',
    })
    .then((res)=>[
        console.log(res),
        level.value=res.data
    ])
    .catch((err)=>{
        console.log(err);
    })
}

const add=(id:any)=>{
    router.push({
        path:'/officeshow',
        query:{
            id:id
        }
    })
}
</script>

<style scoped>

</style>